#pragma warning disable 0618
using System;
using System.Collections.Generic;
using Table.DataModel;
namespace Table.Dao
{
    public class TableShipDao:DaoBase<TableShip>
    {
        public override string GetFileName()
        {
            return "TableShip.csv";
        }
        public override void BuildIndex()
        {
            if (cacheList != null)
            {
                cachePrimaryInt = new Dictionary<int, TableShip>(cacheList.Count);
            }
            base.BuildIndex();
        }
        public override void AddPrimaryIndex(TableShip model)
        {
            #if UNITY_EDITOR
            if(cachePrimaryInt.ContainsKey(model.shipId)) UnityEngine.Debug.LogError("数据表id重复:TableShip->id: " + model.shipId);
            #endif
            cachePrimaryInt[model.shipId] = model;
        }
        protected override TableShip ParseRowData(string[] rowData)
        {
            TableShip data = new TableShip();
            if (!string.IsNullOrEmpty(rowData[0]))
            {
                data.shipId = int.Parse(rowData[0]);
            }
            if (!string.IsNullOrEmpty(rowData[1]))
            {
                data.shipName = rowData[1];
            }
            if (!string.IsNullOrEmpty(rowData[2]))
            {
                data.modelId = int.Parse(rowData[2]);
            }
            if (!string.IsNullOrEmpty(rowData[3]))
            {
                data.shipIcon = string.Intern(rowData[3]);
            }
            if (!string.IsNullOrEmpty(rowData[4]))
            {
                data.isValid = int.Parse(rowData[4]);
            }
            if (!string.IsNullOrEmpty(rowData[5]))
            {
                data.canBuild = int.Parse(rowData[5]);
            }
            if (!string.IsNullOrEmpty(rowData[6]))
            {
                data.itemSubLevel = int.Parse(rowData[6]);
            }
            if (!string.IsNullOrEmpty(rowData[7]))
            {
                data.shipDesc = rowData[7];
            }
            if (!string.IsNullOrEmpty(rowData[8]))
            {
                data.iconOffsetX = float.Parse(rowData[8]);
            }
            if (!string.IsNullOrEmpty(rowData[9]))
            {
                data.iconOffsetY = float.Parse(rowData[9]);
            }
            if (!string.IsNullOrEmpty(rowData[10]))
            {
                data.shipRadius = float.Parse(rowData[10]);
            }
            if (!string.IsNullOrEmpty(rowData[11]))
            {
                data.usfSkills = rowData[11];
            }
            if (!string.IsNullOrEmpty(rowData[12]))
            {
                data.itemInfoIcon = string.Intern(rowData[12]);
            }
            if (!string.IsNullOrEmpty(rowData[13]))
            {
                data.iconScale = float.Parse(rowData[13]);
            }
            return data;
        }
    }
}
